
class Entity(OglEntity):

    def init(self):
        
        self.light_ambient = [0.0, 0.0, 0.0, 1.0]
        self.light_diffuse = [1.0, 1.0, 1.0, 1.0]
        self.light_specular = [1.0, 1.0, 1.0, 1.0]
        # light_position is NOT default value
        self.light_position = [1.0, 1.0, 1.0, 0.0]

        glLightfv(GL_LIGHT0, GL_AMBIENT, self.light_ambient)
        glLightfv(GL_LIGHT0, GL_DIFFUSE, self.light_diffuse)
        glLightfv(GL_LIGHT0, GL_SPECULAR, self.light_specular)
        glLightfv(GL_LIGHT0, GL_POSITION, self.light_position)
        
        glEnable(GL_LIGHTING)
        glEnable(GL_LIGHT0)
        glEnable(GL_DEPTH_TEST)

    def reshape(self, width, height):
        glViewport(0, 0, width, height)
        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        if width <= height:
            glOrtho(-2.5, 2.5, -2.5*height/width,2.5*height/width, -10.0, 10.0)
        else:
            glOrtho(-2.5*width/height,2.5*width/height, -2.5, 2.5, -10.0, 10.0)
        glMatrixMode(GL_MODELVIEW)
        glLoadIdentity()
    
    def display(self, width, height):
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
        glPushMatrix()
        glRotatef(20.0, 1.0, 0.0, 0.0)
        glPushMatrix()
        glTranslatef(-0.75, 0.5, 0.0);
        glRotatef(90.0, 1.0, 0.0, 0.0)
        gtk.gdkgl.draw_torus(True, 0.275, 0.85, 15, 15)
        glPopMatrix()
        
        glPushMatrix()
        glTranslatef(-0.75, -0.5, 0.0);
        glRotatef(270.0, 1.0, 0.0, 0.0)
        gtk.gdkgl.draw_cone(True, 1.0, 2.0, 15, 15)
        glPopMatrix()
        
        glPushMatrix()
        glTranslatef(0.75, 0.0, -1.0)
        gtk.gdkgl.draw_sphere(True, 1.0, 15, 15)
        glPopMatrix()
        glPopMatrix()
    
